package com.ruoyi.business.statistics.controller;

import com.ruoyi.business.seaTotal.domain.SeaTotalData;
import com.ruoyi.business.statistics.domain.StatisticsData;
import com.ruoyi.business.statistics.service.ISeaStatisticsService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Description 统计管理
 *
 * @author 李国臻
 * @date 2025-04-22 08:38
 */
@RestController
@RequestMapping("/sea/statistics")
public class StatisticsController extends BaseController {
    @Resource
    private ISeaStatisticsService seaStatisticsService;

    @GetMapping("/list")
    public TableDataInfo list(StatisticsData statisticsData)
    {
        startPage();
        List<StatisticsData> list = seaStatisticsService.selectStatisticsDataList(statisticsData);
        return getDataTable(list);
    }

    /**
     * 导出海洋数据总览列表
     */
    @Log(title = "海洋数据总览", businessType = BusinessType.EXPORT)
    @PostMapping("/exportStatistics")
    public void exportStatistics(HttpServletResponse response, StatisticsData statisticsData)
    {
        List<StatisticsData> list = seaStatisticsService.selectStatisticsDataList(statisticsData);
        ExcelUtil<StatisticsData> util = new ExcelUtil<>(StatisticsData.class);
        util.exportExcel(response, list, "数据汇总");
    }



}
